package com.jwm.power.repository;

import com.jwm.power.model.entity.Deptjob;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;
public interface JobsRepository extends JpaRepository<Deptjob, Integer>, JpaSpecificationExecutor<Deptjob> {
    //  获取最大编码
    @Query(value = "select top 1 RIGHT(jobcode,2) from Deptjob where ParentCode=?1 order by jobcode DESC ", nativeQuery = true)
    String getMaxCode(String parentCode);

    Deptjob findByJobcode(@Param("jobcode") String jobCode);
    List<Deptjob> findByParentcodeAndJobname(@Param("parentcode") String parentcode,@Param("jobname") String jobname);
    List<Deptjob> findByParentcodeAndJobnameAndJobidNot(@Param("parentcode") String parentcode,@Param("jobname") String jobname,@Param("jobid") Integer jobid);
}
